package com.wedu.view;

import com.wedu.service.StudentService;
import com.wedu.service.impl.StudentServiceImpl;
import com.wedu.util.TSUtils;
import org.junit.Test;

import java.sql.SQLException;
import java.util.Scanner;

/**
 * @author 乱码酱
 * @date ：2022-09-29 11:01
 * @program: javaUBD
 * @create:修改学生信息2
 */
public class Update2 {
    private StudentService studentService = new StudentServiceImpl();
    private Scanner sc = new Scanner(System.in);

    //修改测试2
    @Test
    public void update() throws SQLException {
        System.out.println("***修改界面***");
        System.out.println("请输入要修改的学生id：");
        int id = TSUtils.ageStock();
        System.out.println("请输入修改后的学生姓名name：");
        String name = TSUtils.readKeyBoard(15, false);
        System.out.println("请输入修改后的学生性别sex：");
        String sex = TSUtils.readKeySex(1);
        System.out.println("请输入修改后的学生年龄age：");
        int age = TSUtils.ageStock();
        System.out.println("请输入修改后的学生密码password：");
        String password = TSUtils.readKeyBoard(6, false);
        //2.调用方法
        studentService.updateMsgStu(id,name,sex,age,password);
        //成功
        System.out.println("修改成功！");

        System.out.println("退出");
        System.out.print("确认是否退出(Y/N)：");
        if (TSUtils.readConfirmSelection() == 'Y' || TSUtils.readConfirmSelection() == 'y') {
            System.out.println("您已成功退出，谢谢使用！");
            System.exit(0);  //JVM退出
        }

    }
}
